//
//  YZNetworkManager+Home.m
//  YZMicroStock
//
//  Created by wangminhong on 16/4/6.
//  Copyright © 2016年 cqjr. All rights reserved.
//

#import "YZClient+Home.h"

@implementation YZNetworkManager (Home)

- (void)fetchHomeDataListWithSuccess:(void (^)(NSURLResponse *task,id responseObject))success failure: (void (^)(NSError *error))failure {
    
    [self.mainNetwork cq_noCacheGET:URL_FOR_FETCH_HOME_DATA_LIST parameters:@{@"device": @"3"}
                             success:^(NSURLSessionDataTask *task, id responseObject) {
                                 if (success) {
                                     success(task.response, responseObject);
                                 }
                             } failure:^(NSURLSessionDataTask *task, NSError *error) {
                                 if (failure) {
                                     failure(error);
                                 }
                             }];
}

- (void)fetchSeverTimeWithSuccess:(void (^)(NSURLResponse *, id))success failure:(void (^)(NSError *))failure{
    
    [self.mainNetwork cq_noCacheGET: URL_FOR_FETCH_SEVER_TIME parameters: nil
                            success:^(NSURLSessionDataTask *task, id resObj) {
                                if (success) {
                                    
                                    success(task.response, resObj);
                                }
                            } failure: ^(NSURLSessionDataTask *operation, NSError *error) {
                                if (failure) {
                                    failure(error);
                                }
                            }];
}


- (void)checkSoftwareUpdateSuccess:(void (^)(NSURLResponse *, id))success failure:(void (^)(NSError *))failure{
    
    NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
    NSString *app_Version = [infoDictionary objectForKey:@"CFBundleVersion"];
    
    NSDictionary *params = @{COMMON_REQUEST_DEVICE: COMMON_REQUEST_DEVICE_VALUE, @"version":app_Version};
    
    [self.mainNetwork cq_noCacheGET: URL_FOR_CHECK_SOFTWARE_UPDATE parameters: params
                            success:^(NSURLSessionDataTask *task, id resObj) {
                                if (success) {
                                    
                                    success(task.response, resObj);
                                }
                            } failure: ^(NSURLSessionDataTask *operation, NSError *error) {
                                if (failure) {
                                    failure(error);
                                }
                            }];
}


- (void)fetchHomeBannerListWithSuccess:(void (^)(NSURLSessionDataTask *task,id responseObject))success
                       failure: (void (^)(NSError *error))failure {
    
    NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
    NSString *buildVersion = [infoDictionary objectForKey:@"CFBundleVersion"];
    NSDictionary *params = @{COMMON_REQUEST_DEVICE: COMMON_REQUEST_DEVICE_VALUE, @"version":buildVersion};
    
    [self.mainNetwork cq_noCacheGET: URL_FOR_FETCH_HOME_BANNER parameters: params
                            success:^(NSURLSessionDataTask *task, id responseObject) {
                                if (success) {
                                    success(task, responseObject);
                                }
                            } failure: ^(NSURLSessionDataTask *task, NSError *error) {
                                if (failure) {
                                    failure(error);
                                }
                            }];
}

- (void)fetchRankListWithSuccess:(void (^)(NSURLSessionDataTask *task,id responseObject))success
                         failure: (void (^)(NSError *error))failure{
    
    NSDictionary *params = @{COMMON_REQUEST_DEVICE: COMMON_REQUEST_DEVICE_VALUE};
    
    [self.mainNetwork cq_noCacheGET: URL_FOR_FETCH_HOME_DATA_LIST parameters: params
                            success:^(NSURLSessionDataTask *task, id responseObject) {
                                if (success) {
                                    success(task, responseObject);
                                }
                            } failure: ^(NSURLSessionDataTask *task, NSError *error) {
                                if (failure) {
                                    failure(error);
                                }
                            }];
}


-(void)fetchHomeTrendListWithSuccess:(void (^)(NSURLSessionDataTask *, id))success failure:(void (^)(NSError *))failure{
    
    NSDictionary *params = @{COMMON_REQUEST_DEVICE: COMMON_REQUEST_DEVICE_VALUE};
    
    [self.mainNetwork cq_noCacheGET: URL_FOR_GET_HOME_TREND_LIST parameters: params
                            success:^(NSURLSessionDataTask *task, id responseObject) {
                                if (success) {
                                    success(task, responseObject);
                                }
                            } failure: ^(NSURLSessionDataTask *task, NSError *error) {
                                if (failure) {
                                    failure(error);
                                }
                            }];
    
}


-(void)fetchHomeRankListWithSuccess:(void (^)(NSURLSessionDataTask *, id))success failure:(void (^)(NSError *))failure{
    
    NSDictionary *params = @{COMMON_REQUEST_DEVICE: COMMON_REQUEST_DEVICE_VALUE};
    
    [self.mainNetwork cq_noCacheGET: URL_FOR_GET_HOME_RANK_LIST parameters: params
                            success:^(NSURLSessionDataTask *task, id responseObject) {
                                if (success) {
                                    success(task, responseObject);
                                }
                            } failure: ^(NSURLSessionDataTask *task, NSError *error) {
                                if (failure) {
                                    failure(error);
                                }
                            }];
}


@end
